﻿using Autofac;
using System.Reflection;
using WLYT.Application.Interfaces;
using WLYT.Application.Services;
using WLYT.Core;

namespace WLYT.WMS.Component
{
    public class AutoRegisterModule : Autofac.Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            #region Service
            var assemblysServices = Assembly.Load("WLYT.Application");
            builder.RegisterAssemblyTypes(assemblysServices).AsImplementedInterfaces().InstancePerDependency();
            #endregion Service

            #region Redis
            var assemblysRedis = Assembly.Load("WLYT.Redis");
            builder.RegisterAssemblyTypes(assemblysRedis).AsImplementedInterfaces().InstancePerDependency();
            #endregion Service

            builder.RegisterGeneric(typeof(BaseService<>)).As(typeof(IBaseService<>)).SingleInstance();
            builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>)).SingleInstance();
        }
    }
}
